export const menuData = [
    {
        id: "1",
        title: "首页",
        path: "/Home/home",
    },
    {
        id: "2",
        title: "轮播图",
        children: [
            {
                id: "2-1",
                title: "轮播图列表",
                path: "/Home/Banner",
            },
            {
                id: "2-2",
                title: "添加轮播图",
                path: "/Home/AddBanner",
            },
        ],
    },
    {
        id: "3",
        title: "操作人员管理",
        children: [
            {
                id: "3-1",
                title: "操作人员列表",
                path: "/Home/Operators",
            },
            {
                id: "3-2",
                title: "操作人员添加",
                path: "/Home/AddOperators",
            },
        ],
    },
    {
        id: "4",
        title: "产品管理",
        children: [
            {
                id: "4-1",
                title: "秒杀列表",
                path: "/Home/productmiaosha",
            },
            {
                id: "4-2",
                title: "推荐列表",
                path: "/Home/recommendation",
            },
            {
                id: "4-3",
                title: "筛选列表",
                path: "/Home/screen",
            },
            {
                id: "4-4",
                title: "商品分类列表",
                path: "/Home/classification",
            },
            {
                id: "4-5",
                title: "产品列表",
                path: "/Home/productlist",
            },
        ],
    },
    {
        id: "5",
        title: "地图",
        path: "/Home/atlas",
    },
    {
        id: "6",
        title: "Eatchs",
        children:
            [
                {
                    id: "6-1",
                    title: "eatch",
                    path: "/Home/eatch",
                },
                {
                    id: "6-2",
                    title: "eatch2",
                    path: "/Home/eatch2",
                },
            ]
    },
    {
        id: "7",
        title: "订单管理",
        children:
            [
                {
                    id: "7-1",
                    title: "订单列表",
                    path: "/Home/order",
                }
            ]
    }
]

// 根据用户权限
export const getCurrentMenu = () => {
    const checkedkeys = localStorage.getItem("checkedkeys")?.split(',');
    console.log(checkedkeys);
    let CurrentMenuData:any = []

    menuData.forEach((item) => {
        if (checkedkeys.includes(item.id)) {
            CurrentMenuData.push({ ...item });
            CurrentMenuData[CurrentMenuData.length - 1].children = [];
            if (item.children && Array.isArray(item.children) && item.children.length > 0) {
                item.children.forEach(sonItem => {
                    if (checkedkeys.includes(sonItem.id)) {
                        CurrentMenuData[CurrentMenuData.length - 1].children.push({ ...sonItem });
                    }
                })
            }
        }

    })

    return CurrentMenuData

    // ["1","2","3","3-1"]
}